package com.sky.controller.admin;

import com.sky.config.Redisconfiguration;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController("adminshopcontroller")
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    /*店铺的营业和打烊*/
    @PutMapping("/{status}")
    @ApiOperation("打烊营业")
    public Result  status(@PathVariable Integer status){
           log.info("店铺的营业还是打烊：{}",status==1?"营业":"打烊");
               redisTemplate.opsForValue().set("SHOP_STATUS",status);
       return Result.success();
    }

@GetMapping("/status")
@ApiOperation("管理员查询店铺状态")
    public Result  getstatus(){
       Integer status1= (Integer)  redisTemplate.opsForValue().get("SHOP_STATUS");
    log.info("查看店铺状态:{}",status1==1?"营业":"打烊");
        return  Result.success(status1);
}



}
